from django.urls import path, register_converter

from apps.users.views import Username, RegisterView, UserMobile, LogoutView, UserInfoView, LoginView, SaveEmailView, \
    EmailVerifyView, AddressCreateView, AddressView, PasswordView

from utils.converter import UsernameConverter, MobileConverter

register_converter(UsernameConverter, 'uname')  # 后端一定要验证数据
register_converter(MobileConverter, 'umobile')

urlpatterns = [
    path('usernames/<uname:username>/count/', Username.as_view()),  # 注册判断用户名是否存在
    path('mobiles/<umobile:usermobile>/count/', UserMobile.as_view()),  # 判断注册时手机号是否存在
    path('register/', RegisterView.as_view()),  # 注册存入信息
    path('logout/', LogoutView.as_view()),  # 注册存入信息
    path('info/', UserInfoView.as_view()),
    path('login/', LoginView.as_view()),
    path('emails/', SaveEmailView.as_view()),
    path('emails/verification/', EmailVerifyView.as_view()),
    path('addresses/create/', AddressCreateView.as_view()),
    path('addresses/', AddressView.as_view()),
    path('addresses/<id>/', AddressView.as_view()),
    path('password/', PasswordView.as_view()),
]
